<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Products extends BIT_Controller
{
	function __construct() {
		parent::__construct();

		$this->header_views = array('admin/header');
		$this->footer_views = array('admin/footer');

		$data['loggedin'] = $this->tank_auth->is_logged_in();
		$this->view_data['widgets'] = array(
			$this->load->view('widgets/loginwidget', $data, TRUE)
		);
	}
	
	public function index() {
		$this->load->library('adminlib');
		$this->view_data['products'] = $this->adminlib->getProductList();
		$this->v('admin/produkter/list');
	}
	public function edit($id) {
		$this->load->library('adminlib');
		if($_POST) {
			$data = $_POST;
			unset($data['submit']);
			$this->load->model('produkter');
			$this->produkter->saveProduct($data);
		}
		$this->view_data['product'] = $this->adminlib->getProduct($id);
		$this->v('admin/produkter/edit');
	}
}